<?php
/*for($i=0; $i<$tags->count(); $i++)
{
	$tag = $tags->current();
	echo "<div><a class='ui-helper-reset' user_id='".$tag->get("id")."' href='#profile/".$tag->get("id")."'>".$tag->get("name")."<a></div>";
	$tags->next();
}
echo "<br><div align='center'><button id='but-addTag'>".__("Add tag")."</button></div>";
*/
//echo json_encode(array("title"=>__("Tags"),"body"=>$body));
?>
<div class="accordion" total="<?php echo $total;?>">
<?php
foreach($messages as $messageRel){
	//TODO cambiar aqui cuando se cambie la parte de getPrivatemessages de sfGuardUser
	$message = $messageRel->getPrivateMessage();
	$subject = $message->getBody();
	if(strlen($subject) > 20)
		$subject = substr($subject,0,17)."...";

		//Check if is new
		$q = Doctrine_Query::create()
  				->select("sum(new) as new")
  				->from('PrivateMessage')
  				->where('conversation_id = ?',$message->getConversationId())
  				->addWhere('user_id = ?',$userId);
  		$res = $q->execute();

	if($res[0]['new']>0)
		$new = "class='ui-state-highlight'";
	else
		$new = "";
?>
		<h3 message="<?php echo $message->getConversationId();?>"><a href="#" <?php echo $new; ?>><?php echo $subject; ?> [<?php echo $message->getCreatedAt();?>]<img src="images/cruzTemporal.png" class="move" style="float:right;" /></a></h3>
		<div><div id="<?php echo $message->getConversationId();?>"  align="center"><img src="images/progress.gif"/></div></div>
<?php
} 
?>
</div>
<div class="paginator"></div>